<script setup lang='ts'>
import { inject } from 'vue';

const realMoney = inject<number>('money', 0)
const costMoneyFunc = inject<(money:number)=>void>('cost')
const cutMoney = () => {
    if(costMoneyFunc){
        costMoneyFunc(9999)
    }
}
</script>

<template>
    <h3>我是孙子</h3>
    <p>得到爷爷给的零花钱{{ realMoney }}</p>
    <button @click="cutMoney">买车</button>
</template>

<style scoped></style>